//
//  MainViewController.m
//  JZ100
//
//  Created by lj on 15/9/2.
//  Copyright © 2015年 itcast. All rights reserved.
//

#import "MainViewController.h"
#import "ActivityViewController.h"
#import "JobTableViewController.h"
#import "ProfileViewController.h"

@interface MainViewController ()

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self.tabBar setTintColor:[UIColor darkGrayColor]];
    [self addChildViewControllers];

}

// MARK: 添加控制器

/// 添加子控制器
-(void)addChildViewControllers
{
    [self addChildViewController:[[ActivityViewController alloc]init] WithTitleName:@"活动" imageName:@"activity_n" selectedImageName:@"activity_s"];
    [self addChildViewController:[JobTableViewController new] WithTitleName:@"兼职" imageName:@"job_n" selectedImageName:@"job_s"];
    [self addChildViewController:[ProfileViewController new] WithTitleName:@"我的" imageName:@"mine_n" selectedImageName:@"mine_s"];
    
}

/// 创建单个子控制器
///
/// @param childController 子控制器
/// @param titleName       控制器的tabBarItem名字
/// @param imageName       图片名字
-(void)addChildViewController:(UIViewController *)childController WithTitleName:(NSString *)titleName imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImgName
{

    childController.title = titleName;
    
    childController.tabBarItem.image = [[UIImage imageNamed:imageName]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    childController.tabBarItem.selectedImage =[[UIImage imageNamed:selectedImgName]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UINavigationController* nav = [[UINavigationController alloc]initWithRootViewController:childController];
    
    [self addChildViewController:nav];
    
}

@end
